package com.web.dao;

import static org.apache.ibatis.jdbc.SqlBuilder.BEGIN;
import static org.apache.ibatis.jdbc.SqlBuilder.INSERT_INTO;
import static org.apache.ibatis.jdbc.SqlBuilder.SET;
import static org.apache.ibatis.jdbc.SqlBuilder.SQL;
import static org.apache.ibatis.jdbc.SqlBuilder.UPDATE;
import static org.apache.ibatis.jdbc.SqlBuilder.VALUES;
import static org.apache.ibatis.jdbc.SqlBuilder.WHERE;

import com.web.entity.Platform;

/**
 * @author FDjavaone
 */
public class PlatformSqlProvider {

    public String insertSelective(Platform record) {
        BEGIN();
        INSERT_INTO("t_platform");
        
        if (record.getCompanyProfitPool() != null) {
            VALUES("company_profit_pool", "#{companyProfitPool,jdbcType=DECIMAL}");
        }
        
        if (record.getCompanyFundPool() != null) {
            VALUES("company_fund_pool", "#{companyFundPool,jdbcType=DECIMAL}");
        }
        
        if (record.getMarketFundPool() != null) {
            VALUES("market_fund_pool", "#{marketFundPool,jdbcType=DECIMAL}");
        }
        
        if (record.getBonusPool() != null) {
            VALUES("bonus_pool", "#{bonusPool,jdbcType=DECIMAL}");
        }

        if (record.getPoundagePool() != null) {
            VALUES("poundage_pool", "#{poundagePool,jdbcType=DECIMAL}");
        }

        if (record.getMarketMsk() != null) {
            VALUES("market_msk", "#{marketMsk,jdbcType=DECIMAL}");
        }
        
        if (record.getCompanyMsk() != null) {
            VALUES("company_msk", "#{companyMsk,jdbcType=DECIMAL}");
        }
        
        if (record.getCreateTime() != null) {
            VALUES("create_time", "#{createTime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getModifyTime() != null) {
            VALUES("modify_time", "#{modifyTime,jdbcType=TIMESTAMP}");
        }
        
        return SQL();
    }

    public String updateByPrimaryKeySelective(Platform record) {
        BEGIN();
        UPDATE("t_platform");
        
        if (record.getCompanyProfitPool() != null) {
            SET("company_profit_pool = #{companyProfitPool,jdbcType=DECIMAL}");
        }
        
        if (record.getCompanyFundPool() != null) {
            SET("company_fund_pool = #{companyFundPool,jdbcType=DECIMAL}");
        }
        
        if (record.getMarketFundPool() != null) {
            SET("market_fund_pool = #{marketFundPool,jdbcType=DECIMAL}");
        }
        
        if (record.getBonusPool() != null) {
            SET("bonus_pool = #{bonusPool,jdbcType=DECIMAL}");
        }

        if (record.getPoundagePool() != null) {
            SET("poundage_pool = #{poundagePool,jdbcType=DECIMAL}");
        }

        if (record.getMarketMsk() != null) {
            SET("market_msk = #{marketMsk,jdbcType=DECIMAL}");
        }
        
        if (record.getCompanyMsk() != null) {
            SET("company_msk = #{companyMsk,jdbcType=DECIMAL}");
        }
        
        if (record.getCreateTime() != null) {
            SET("create_time = #{createTime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getModifyTime() != null) {
            SET("modify_time = #{modifyTime,jdbcType=TIMESTAMP}");
        }
        
        WHERE("id = #{id,jdbcType=BIGINT}");
        
        return SQL();
    }
}